$(document).ready(function(){
	
	loadZone();
});

function loadZone() {
	$.ajax({
		url : "CS43003Srvl", 
		type : "POST",
		data : {
			process_type: "getZone"
		},
	//	anync:false,
		dataType:"JSON",
		success: function(data){
			var selected="";
			var options = '';
			options += '<option value="">-- เลือกเขต --</option>';
			for (var i = 0; i < data.values.length; i++) {
				options += '<option value="' + data.values[i] + '" '+selected+'>' + data.messages[i] +  '</option>';
			}
			$("select[name=zone]#inputZone").html(options);
		}
	});
}

function printReport() {
	var vaZone = $("#inputZone").val();
	var vaDateStart = $("#datetimepicker1").val();
	var vaDateEnd = $("#datetimepicker2").val();
	var vnSiteId = $("#siteId").val();
	
	if(vaZone.trim().length == 0 || vaDateStart.trim().length == 0 || vaDateEnd.trim().length == 0 )
	{

		$("#modal_content").html("กรุณากรอกข้อมูลให้ครบถ้วน");
		$("#warningModal").modal();
		return;
	}else{

		var url = reporturl+"CS43003R.jsp?vnSiteId="+vnSiteId+"&vnZoneId="+vaZone+"&vaFromDate="+vaDateStart+"&vaToDate="+vaDateEnd;
		window.open(url);

	}
	
}